<!--

Saherace - Rent a Car

This page is never visible for the customer. It is necessary because 
should not make a new rental when refreshing the confirmation.php. So
this code below does the reservation.

-->

<?php

//Include the soap client connection and the header area of the website
include('includes/header.php');

//If the rent form was posted
if(isset($_POST['rent'])) {
	
	$start_date = str_replace('Z', '', $_SESSION['start_date']);
	$end_date = str_replace('Z', '', $_SESSION['end_date']);

	//Create an array with parameters for rental
	$params = array('car_id' 		=> $_SESSION['car_id'],
					'customer_id' 	=> $_SESSION['customer_id'],
					'start_station'	=> $_SESSION['start_station'],
					'end_station'	=> $_SESSION['end_station'],
					'start_date'	=> $start_date,
					'end_date'		=> $end_date);
	
	//Insert the rental
	$insertNewRental = $client->insertNewRental($params);
	$_SESSION['rental_id'] = $insertNewRental->return;
}

//And forward to the confirmation page
echo '<script>'.
		'document.location.href="confirmation.php"; '.
	 '</script>';

//Include the footer area of the website
include('includes/footer.php');

?>